#!/usr/bin/env python3
# -*- coding: utf-8 -*-
"""
@Author          : ricsy
@File            : seo.py
@Create Time     : 2025/6/18 04:47
@Last Modified   :
@Description     :
"""
from typing import Dict

import sphinx
from theme_customizer.base import BaseCustomizer
from utils.time_utils import TimeUtils


class SEOManager(BaseCustomizer):
    """管理 SEO 相关定制"""

    def apply(self):
        self.app.config.myst_html_meta = self._default_meta()

    def _default_meta(self) -> Dict[str, str]:
        """生成默认 meta 标签"""

        author = self.app.config.author
        project = self.app.config.project
        release = self.app.config.release
        return {
            # ======================== 基础SEO ========================
            "author": author,
            "keywords": "更快,更好,更准确,AI,人工智能,博客,文档,技术手册",
            "description": f"{project} 个人博客文档 - 版本 {release}",
            # ======================== OpenGraph (社交媒体分享) ========================
            "og:title": f"{project} 个人博客文档",
            "og:type": "website",
            "og:url": "https://your-docs-site.com",  # 替换为实际URL
            "og:image": "https://your-docs-site.com/static/og-image.png",  # 1200x630像素
            "og:site_name": f"{project}",
            "og:description": f"{project} 个人博客文档 - {release}版本",
            "og:locale": "zh_CN",
            # ======================== 动态生成 ========================
            "generator": f"Sphinx {sphinx.__version__} with MyST",
            "updated": TimeUtils.get_current_date(),
            # ======================== 移动端优化 ========================
            "theme-color": "#3a86ff",  # 主题色
        }
